function transformNum(value) {
  if (isNaN(value)) {
    return null;
  }

  if ((value + "").match(/^\d+\.\d+$/) == null) {
    return null;
  } else {
    return value * 1;
  }
}
export default {
  created() {
    if (this.item && this.item.vdFloatMax !== undefined) {
      var label = this.item.getLabel();
      this.$emit("componentNotify", "addRule", {
        field: this.item.name,
        rules: [
          {
            type: "float",
            required: true,
            transform: transformNum,
            message: "请填写" + label + "，必须为小数"
          },
          {
            type: "float",
            max: this.item.vdFloatMax,
            message: label + "必须小于" + this.item.vdFloatMax
          }
        ]
      });
    }
  }
};
